#include <bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(int i = a; i <= b; i++)
#define For2(i,a,b) for(int i = a; i >= b; i--)
using namespace std;
const int N = 1e5 + 1;
const double zero = 1e-5;
int n,m,l,V,de[N],cnt;
bool ok[N];
struct car{
    int d,v,a;
} c[N];
bool check(int pos,int i) {
    double weiyi = de[pos]-c[i].d;
    weiyi *= (2*c[i].a);
    double tmp = (c[i].v*c[i].v) + weiyi;
    if (tmp < 0) return false;
    else if (sqrt(tmp) - V > zero) {
        return true;
    }
    return false;
}
void work() {
    cin >> n >> m >> l >> V;
    For (i,1,n) cin >> c[i].d >> c[i].v >> c[i].a;
    For (i,1,m) {
        cin >> de[i];
        ok[i] = true;
    }
    sort(de + 1,de + m + 1);
    For (i,1,n) {
        if (c[i].a == 0) {
            if (c[i].d <= de[m] && c[i].v > V) {
                cnt++;
                ok[m] = false;
            }
        }
        if (c[i].a > 0) {
            if (c[i].d > de[m]) continue;
            else {
                double weiyi = de[m]-c[i].d;
                weiyi *= (2*c[i].a);
                double tmp = (c[i].v*c[i].v) + weiyi;
                if (sqrt(tmp) - V > zero) {
                    cnt++;
                    ok[m] = false;
                }
            }
        }
        if (c[i].a < 0) {
            int l = 1,r = m,tmp = -1;
            while (l <= r) {
                int mid = (l + r) / 2;
                if (check(mid,i) && de[mid] >= c[i].d) {
                    l = mid + 1;
                    tmp = mid;
                }else r = mid - 1;
            }
            if (tmp == -1) continue;
            else {
                cnt++;
                ok[tmp] = false;
            }
        }
    }
    cout << cnt << " ";
    int ans = 0;
    For (i,1,m) {
        if (ok[i]) ans++;
    }
    cout << ans << endl;
}

int main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int _; cin >> _;
    while (_--) work();
    return 0;
}


